#include <cmath>
#include <iostream>

using namespace std;

double f(double x, double y)
{
    return 6.0 * x + 5.0 * y;
}


int main()
{
    double A[2][4], B[4];
    double AA[2][2];
    double x0 = -1.0;
    double y0 = -2.0;
    for(size_t j = 0; j < 4; j++)
    {
        A[0][j] = j - x0;
        A[1][j] = j + 1.0 - y0;
        B[j] = f(A[0][j]+x0, A[1][j]+y0) - f(x0, y0);
    }



    for(size_t i = 0; i < 2; i++)
    {
        for(size_t k = 0; k < 2; k++)
        {
            double temp = 0.0;
            for(size_t j = 0; j < 4; j++)
            {
                temp += A[i][j] * A[k][j];
            }
            AA[i][k] = temp;
        }

    }

    for(size_t i = 0; i < 2; i++)
    {
        for(size_t j = 0; j < 2; j++)
        {
            cout << AA[i][j] << endl;
        }
    }
    double C[2];
    for(size_t i = 0; i < 4; i++)
    {
        cout << B[i] << endl;
    }


    for(size_t i = 0; i < 2; i++)
    {
        double temp = 0;
        for(size_t j = 0; j < 4; j++)
        {
            temp  += B[j] * A[i][j];
        }
        C[i] = temp;
        
    }

    cout << C[0] << "   " << C[1] << endl;
    double Ax = 0.0;
    double Ay = 0.0;

    double temp = AA[0][0] * AA[1][1] - AA[0][1] * AA[1][0];
    Ax = (C[0] * AA[1][1] - AA[0][1] * C[1]) / temp;
    Ay= -(C[0] * AA[1][0] - AA[0][0] * C[1]) / temp;

    cout << temp << endl;
    cout << Ax << "  " << Ay << endl;

        


    return 0;
}
